package user

import (
	"context"
)

const (
	AppName = "users"
)

type Service interface {
	// 用户管理
	// 用户创建
	CreateUser(context.Context, *CreateUserReuqest) (*User, error)
	//查询用户详情
	DescribeUser(ctx context.Context, in *DescribeUserRequest) (*User, error)
	// 用户登陆接口
	Login(context.Context, *LoginRequest) (*Token, error)
	// 用户退出接口
	Logout(context.Context, *LogoutRequest) error
	// 校验用户token
	ValidateToken(context.Context, *ValidateTokenRequest) (*Token, error)
}

func NewLoginRequest() *LoginRequest {
	return &LoginRequest{
		Username: NewCreateUserRequest().Username,
		Password: NewCreateUserRequest().Password,
	}
}

type LoginRequest struct {
	Username string `json:"username"`
	Password string
}

func NewLogoutRequest() *LogoutRequest {
	return &LogoutRequest{
		Username: "",
	}
}

type LogoutRequest struct {
	Username string `json:"username"`
}

func NewDescribeUserRequestByName(name string) *DescribeUserRequest {
	return &DescribeUserRequest{
		DescribeBY:    DESCRIBE_BY_NAME,
		DescribeValue: name,
	}
}

func NewDescribeUserRequestByID(ID int) *DescribeUserRequest {
	return &DescribeUserRequest{
		DescribeBY:    DESCRIBE_BY_ID,
		DescribeValue: ID,
	}
}

type DescribeUserRequest struct {
	DescribeBY    DESCRIBE_BY
	DescribeValue any
}

func NewValidateTokenRequest(ak string) *ValidateTokenRequest {
	return &ValidateTokenRequest{
		AccessToken: ak,
	}
}

type ValidateTokenRequest struct {
	AccessToken string
}
